#include "NetConstants.h"

// 完成

namespace LiteNetLib
{
    const int32_t NetConstants::DefaultWindowSize = 64;
    const int32_t NetConstants::SocketBufferSize = 1024 * 1024;
    const int32_t NetConstants::SocketTTL = 255;

    const int32_t NetConstants::HeaderSize = 1;
    const int32_t NetConstants::ChanneledHeaderSize = 4;
    const int32_t NetConstants::FragmentHeaderSize = 6;

    const uint16_t NetConstants::MaxSequence = 32768;
    const int32_t NetConstants::ProtocolId = 11;
    const int32_t NetConstants::MaxUdpHeaderSize = 68;

#if _MSC_VER

    const int32_t NetConstants::FragmentedHeaderTotalSize = 4 + 6;
    const uint16_t NetConstants::HalfMaxSequence = 32768 / 2;
    const int32_t NetConstants::PossibleMtu[7] = 
    {
        576 - 68,     // minimal (RFC 1191)
        1024,                       // most games standard
        1232 - 68,
        1460 - 68,    // google cloud
        1472 - 68,    // VPN
        1492 - 68,    // Ethernet with LLC and SNAP, PPPoE (RFC 1042)
        1500 - 68     // Ethernet II (RFC 1191)
    };

    const int32_t NetConstants::MaxPacketSize = 1500 - 68;

#else

    const int32_t NetConstants::FragmentedHeaderTotalSize = ChanneledHeaderSize + FragmentHeaderSize;
    const uint16_t NetConstants::HalfMaxSequence = MaxSequence / 2;
    const int32_t NetConstants::PossibleMtu[7] = 
    {
        576 - MaxUdpHeaderSize,     // minimal (RFC 1191)
        1024,                       // most games standard
        1232 - MaxUdpHeaderSize,
        1460 - MaxUdpHeaderSize,    // google cloud
        1472 - MaxUdpHeaderSize,    // VPN
        1492 - MaxUdpHeaderSize,    // Ethernet with LLC and SNAP, PPPoE (RFC 1042)
        1500 - MaxUdpHeaderSize     // Ethernet II (RFC 1191)
    };

    const int32_t NetConstants::MaxPacketSize = PossibleMtu[6];

#endif


    const uint8_t NetConstants::MaxConnectionNumber = 4;
    const int32_t NetConstants::PacketPoolSize = (1024 * 8);

    // 重发时间间隔
    int32_t NetConstants::PacketResendDelay = 60;

    const int32_t NetConstants::DisconnectTimeout = 6000;

    const int32_t NetConstants::StandardPacketSize = 1024;

    uint32_t NetConstants::banIpLimitPackageCount = 1000;
    uint32_t NetConstants::secondClearPackageCount = 100;

    uint32_t NetConstants::secondClearBan = 900000;
}